package com.complaint.dao.impl;

import java.util.*;
import com.complaint.dao.BaseDAO;
import com.complaint.dao.ManagerDAO;
import com.complaint.pojo.Complaint;
import com.complaint.pojo.Manager;

/**
 * UserDAOImpl 是UserDAO的实例类
 *
 * */
public class ManagerDAOImpl extends BaseDAO implements ManagerDAO {
    @Override
    public int add(Manager manager) {
        String sql = "insert into managerTable values(DEFAULT, ?, ?)";
        return update(sql, manager.getName(), manager.getPassword());
    }

    public List<Manager> findByName(String username) {
        String sql = "select password from managerTable where name=?";
        List<Manager> list = sQuery(Manager.class, sql, username);
        return list;
    }

    public int findId(String username) {
        String sql = "select id from managerTable  where name=?";
        return aQuery(Integer.class, sql, username);
    }

    public List<Complaint> findForMain() {
        String sql = "select * from complaintTable";
        return sQuery(Complaint.class, sql);
    }
}
